@echo off

Set /P DBNAME=[Enter database name:] 
Set /P USERNAME=[Enter database UserID:] 
Set /P PASSWORD=[Enter database Password:] 
Set /P SERVERINSTANCE=[Enter Server Name:] 

@Echo -
@Echo.:: Using the following setup values:
@Echo DBname is %DB%
@Echo Username is %USERNAME%
@Echo Password is %PASSWORD%
@Echo Server is %SERVERINSTANCE%
@Echo -
@Pause

Echo.

Set SQLSCRIPTHOME=..\
Set DBHOME=C:\PWS\MSSQL\DATA
Set SQLSCRIPTOUTPUTDIR=%SQLSCRIPTHOME%\Output
Set CORESQLSCRIPTDIR=%SQLSCRIPTHOME%\DBScripts\Core
Set AGGREGATESQLSCRIPTOUTPUTFILE=%SQLSCRIPTOUTPUTDIR%\CreateDB.out

Echo.:: Creating database directory %DBHOME%
Echo.
IF NOT EXIST %DBHOME% MKDIR %DBHOME%

Echo.:: Creating output directory %SQLSCRIPTOUTPUTDIR%
Echo.
IF NOT EXIST %SQLSCRIPTOUTPUTDIR% MKDIR %SQLSCRIPTOUTPUTDIR%

Echo.:: Deleting existing output file %AGGREGATESQLSCRIPTOUTPUTFILE%
Echo.
IF EXIST %AGGREGATESQLSCRIPTOUTPUTFILE% DEL %AGGREGATESQLSCRIPTOUTPUTFILE%

Echo.
Echo.:: Creating database for Personal Website Software
Echo.
Echo -------------------------------------------------------  >> %AGGREGATESQLSCRIPTOUTPUTFILE%
Echo -- DB_Init... >> %AGGREGATESQLSCRIPTOUTPUTFILE%
sqlcmd -U %USERNAME% -P %PASSWORD% -S %SERVERINSTANCE% -i %CORESQLSCRIPTDIR%\PWS_CreateDB.sql  -o %SQLSCRIPTOUTPUTDIR%\PWS_CreateDB.out
Type %SQLSCRIPTOUTPUTDIR%\PWS_CreateDB.out >> %AGGREGATESQLSCRIPTOUTPUTFILE%

Echo.
@Pause
